﻿namespace SimpleWebServices.Web.Mvc
{
    using System;
    using System.Web;
    using System.Web.Mvc;
    using SimpleWebServices.Security.Cryptography;

    public sealed class StyleSheetResult : ActionResult
    {
        public string Content
        {
            get;
            set;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException("context");
            }

            HttpResponseBase response = context.HttpContext.Response;

            if (null != this.Content)
            {
                response.Cache.SetCacheability(HttpCacheability.Public);
                response.Cache.SetETag(MD5Hash.Compute(this.Content));
            }

            response.ContentType = "text/css";

            response.Write(this.Content);
        }
    }
}